package com.bishe.demo.modules.other.entity;

import com.bishe.demo.modules.account.entity.User;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;

import javax.persistence.*;
import javax.transaction.Transactional;
import java.time.LocalDateTime;
import java.util.List;


@Entity
@Table(name = "other_travel")
public class Travel {
    @Id//表示该字段是主键
    @GeneratedValue(strategy = GenerationType.IDENTITY)//表示自增
    @Column(nullable = false, updatable = false)//nullable = false:表示该字段不能为空，updatable = false：表示该字段不能修改
    private int travelId;

    private String travelName;

    @Lob @Basic(fetch = FetchType.LAZY) @Column(columnDefinition = "text")
    private String travelDetail;

    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(updatable = false)
    private LocalDateTime createTime;

    @Transient
    private List<Image> images;

    @Transient
    private User user;

    public int getTravelId() {
        return travelId;
    }

    public void setTravelId(int travelId) {
        this.travelId = travelId;
    }

    public String getTravelName() {
        return travelName;
    }

    public void setTravelName(String travelName) {
        this.travelName = travelName;
    }

    public String getTravelDetail() {
        return travelDetail;
    }

    public void setTravelDetail(String travelDetail) {
        this.travelDetail = travelDetail;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public List<Image> getImages() {
        return images;
    }

    public void setImages(List<Image> images) {
        this.images = images;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}
